﻿using Microsoft.Graphics.Canvas;
using Microsoft.Graphics.Canvas.Effects;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Documents;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using 纸片人.ConvertClass;
using 纸片人.win2dEffectControl.DataClass;
using 纸片人.CalculateControls;
// The Templated Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234235

namespace 纸片人.win2dEffectControl
{
    public class Transform2DEffectControl : EffectControl
    {
        private ComboBox interpolationModeComboBox;
        TextBoxSlider SharpnessSlider;
        Matrix3x2Control matrix3x2Control;
        ComboBox effectBorderModeComboBox;
        List<CanvasImageInterpolation> listImageInterpolation = new List<CanvasImageInterpolation>();
        List<EffectBorderMode> listEffectBorderMode = new List<EffectBorderMode>();
        public override EffectOneSourceData OneEffetData { get; set; }


        public Transform2DEffectControl()
        {
            this.DefaultStyleKey = typeof(Transform2DEffectControl);
            listImageInterpolation = EffectUtil.GetEnumList<CanvasImageInterpolation>();
            listEffectBorderMode = EffectUtil.GetEnumList<EffectBorderMode>();
            OneEffetData = new Transform2DEffectData();
        }

        protected override void OnLoaded()
        {
            var effect = (Transform2DEffect)Effect;
            //matrix3x2Control.SetMatrix3x2(effect.TransformMatrix);
        }
        protected override void OnApplyTemplate()
        {
          

            base.OnApplyTemplate();
            SharpnessSlider = GetTemplateChildFormName<TextBoxSlider>(nameof(SharpnessSlider));
            SetTextBoxSlider(SharpnessSlider, OneEffetData, nameof(Transform2DEffect.Sharpness));

            interpolationModeComboBox = GetTemplateChildFormName<ComboBox>(nameof(interpolationModeComboBox));
            SetComboBox(interpolationModeComboBox, listImageInterpolation, OneEffetData, nameof(Transform2DEffect.InterpolationMode));

            matrix3x2Control = GetTemplateChildFormName<Matrix3x2Control>(nameof(matrix3x2Control));
            SetMatrix3x2Control(matrix3x2Control, OneEffetData, nameof(Transform2DEffectData.TransformMatrix));

            effectBorderModeComboBox = GetTemplateChildFormName<ComboBox>(nameof(effectBorderModeComboBox));
            SetComboBox(effectBorderModeComboBox, listEffectBorderMode,OneEffetData, nameof(Transform2DEffectData.EffectBorderMode));
        }

    }
}
